#define _CRT_SECURE_NO_WARNINGS 1
class Solution {
public:
    int minCost(vector<vector<int>>& costs) {
        int n = costs.size();
        vector<vector<int>> dp(n + 1, vector<int>(3));
        for (int i = 1; i <= n; i++) {

            dp[i][0] = costs[i - 1][0] + min(dp[i - 1][1], dp[i - 1][2]);
            dp[i][1] = costs[i - 1][1] + min(dp[i - 1][0], dp[i - 1][2]);
            dp[i][2] = costs[i - 1][2] + min(dp[i - 1][0], dp[i - 1][1]);

        }
        return min(dp[n][0], min(dp[n][1], dp[n][2]));
    }
};